package com.tourism.website.articlepersonal.mapper;

import com.tourism.website.articlepersonal.entity.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tourism.website.articlepersonal.entity.ArticleCategory;
import com.tourismwebsite.articledisplay.dto.ArticleCategoryDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author kevin
 * @since 2024-06-13
 */
@Mapper
public interface ArticleMapper extends BaseMapper<Article> {
    //删除文章
    @Delete("DELETE FROM article WHERE article_id = #{articleId}")
    int deleteArticleManage(Integer articleId);

    @Select("SELECT * FROM article_category WHERE category_id = #{categoryId} AND article_id IN (${articleIds})")
    List<ArticleCategoryDTO> selectArticlesByCategoryIdAndArticleIds(Integer categoryId, String articleIds);
    @Select("SELECT article_id FROM article WHERE user_id = #{userId}")
    List<Integer> selectArticleIdsByUserId(Integer userId);
}
